#include <iostream>
#include <cstdlib>

#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2

typedef int Status;
typedef int ElemType;

class SqFab
{
private:
	ElemType *base;
	int head, max;

public:
	Status InitQueue(int k);
	Status Execute(int n);
	void Print();
};

Status SqFab::InitQueue(int k)
{
	int i;
	base = (ElemType *)malloc(k * sizeof(ElemType));
	max = k;
	for(i = 0; i < max-1; i++)
		base[i] = 0;
	base[max-1] = 1;
	head = 0;
	return OK;
}

Status SqFab::Execute(int n)
{
	int sum = 1, temp;
	for(int i = max; i < n; i++)
	{
		temp = base[head];
		base[head++] = sum;
		sum = sum * 2 - temp;
		if(head == max)
			head = 0;
	}
	return OK;
}

void SqFab::Print()
{
	int p = head;
	for(int i = 1; i <= max; i++)
	{
		std::cout << base[p++] << " ";
		p %= max;
	}
	std::cout << std::endl;
}